package huachenxing.mimi520.resource
{
	import flash.text.AntiAliasType;
	import flash.text.GridFitType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public class TextIcon extends TextField
	{
		static public var COLOR:uint = 0;
		static public var SIZE:int = 14;
		
		static public function get CLOSE():TextIcon { return i(0xe600); }
		static public function get PAUSE():TextIcon { return i(0xe601); }
		static public function get ACCOUNT():TextIcon { return i(0xe602); }
		static public function get PLAY():TextIcon { return i(0xe603); }
		static public function get OPTIONS():TextIcon { return i(0xe604); }
		static public function get HOME():TextIcon { return i(0xe605); }
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		[Embed(source="../../../../assets/icons/iconfont.ttf", mimeType="application/x-font"
			,embedAsCFF="false", fontFamily="text_icon", fontWeight="normal", fontStyle="normal")]
		static private const _TTF:Class;
		
		static private function i(code:int):TextIcon
		{
			var field:TextIcon = new TextIcon();
			field.type = TextFieldType.DYNAMIC;
			field.mouseEnabled = false;
			field.antiAliasType = AntiAliasType.ADVANCED;
			field.gridFitType = GridFitType.SUBPIXEL;
			field.defaultTextFormat = new TextFormat("text_icon", SIZE, null, null, null, null, null, null, TextFormatAlign.CENTER, 0, 0);
			field.embedFonts = true;
			field.text = String.fromCharCode(code);
			field.autoSize = TextFieldAutoSize.CENTER;
			field.textColor = COLOR;
			return field;
		}
		
		private var _size:int = SIZE;
		public function get size():int
		{
			return _size;
		}
		public function set size(value:int):void
		{
			if(value < 1) value = 1;
			if(value == _size) return;
			_size = value;
			
			var tf:TextFormat = defaultTextFormat;
			tf.size = _size;
			defaultTextFormat = tf;
			setTextFormat(tf);
		}
		
	}
}